package city.spring.modules.material.repository;

import city.spring.modules.material.entity.MaterialwarehousingMaterialExtEntity;
import city.spring.modules.material.vo.MaterialwarehousingMaterialVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 存储库：物资入库与货架关联
 *
 * @author 谢金婷
 * @date 2020-07-17 11:44:42
 */
@Repository
public interface MaterialwarehousingMaterialExtRepository extends BaseMapper<MaterialwarehousingMaterialExtEntity> {
    /**
     * 获取入库的物资列表
     *
     * @param wrapper 查询对象
     * @return
     */
    List<MaterialwarehousingMaterialVO> getMaterials(@Param(Constants.WRAPPER) Wrapper<? extends MaterialwarehousingMaterialExtEntity> wrapper);

    /**
     * 获取入库的物资列表
     *
     * @param materialwarehousingId 入库单ID
     * @return
     */
    List<MaterialwarehousingMaterialVO> getWarehousingMaterials(String materialwarehousingId);

    /**
     * 获取入库的某个物资
     *
     * @param materialwarehousingId 入库ID
     * @param extId                 主键ID
     * @return
     */
    MaterialwarehousingMaterialVO getWarehousingMaterial(String materialwarehousingId, String extId);

    /**
     * 获取入库的物资列表
     *
     * @param materialwarehousingId 入库单ID
     * @return
     */
    List<MaterialwarehousingMaterialExtEntity> getWarehousingMts(String materialwarehousingId);

    /**
     * 根据warehousingId查找该warehousingId下的入库物资
     *
     * @param materialwarehousingId
     * @return
     */
    List<MaterialwarehousingMaterialExtEntity> getByWarehousingId(String materialwarehousingId);

    /**
     * 根据入库单id，物资id和仓库id查找物资
     *
     * @param materialwarehousingId
     * @param storehouseId
     * @param materialId
     * @return
     */
    MaterialwarehousingMaterialExtEntity getByMaterialwarehousingIdAndMaterialIdAndStorehouseId(String materialwarehousingId, String materialId, String storehouseId);

    /**
     * 根据物资id查找入库物资
     *
     * @param materialId
     * @return
     */
    IPage<MaterialwarehousingMaterialExtEntity> getByMaterialId(Page<? extends MaterialwarehousingMaterialExtEntity> page, @Param(Constants.WRAPPER) Wrapper<? extends MaterialwarehousingMaterialExtEntity> wrapper, @Param("materialId") String materialId);

    IPage<MaterialwarehousingMaterialExtEntity> getMaterialWarehouseList(Page<? extends MaterialwarehousingMaterialExtEntity> page, @Param("storehouseId") String storehouseId, @Param("materialId") String materialId);
}